package com.yisu.auction.api.core.service.impl;

import com.yisu.auction.api.core.mapper.SystemConfigMapper;
import com.yisu.auction.api.core.service.BaseService;
import com.yisu.auction.api.core.service.ISystemConfigService;
import com.yisu.auction.api.domain.config.SystemConfig;
import com.yisu.auction.api.domain.vo.indexPackageVos.SystemConfigVo;
import com.yisu.auction.ewf.common.utils.QiNiuUploadUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * author: 赵杰
 * Business Description：系统参数业务接口实现
 * createTime：2017/8/16
 */
@Service("ISystemConfigService")
public class SystemConfigServiceImpl extends BaseService implements ISystemConfigService {

    @Resource
    private SystemConfigMapper systemConfigMapper;
    /**
     *  author: 赵杰
     * Business Description：获取APP初始加载时候的系统参数
     *
     * @return
     */
    @Override
    public List<SystemConfigVo> getAppLoadConfig(String appSign) {
        return systemConfigMapper.getAppLoadConfig(appSign);
    }


    /**
     * author: Nichole
     * Business Description: 获取七牛Token
     * @return
     */
    @Override
    public String getQiNiuUploadToken() {
        QiNiuUploadUtil.Uploader uploader = new QiNiuUploadUtil.Uploader();
        uploader.setAccessKey(systemConfig.getQiNiuAccessKey());
        uploader.setSecretKey(systemConfig.getQiNiuSecretKey());
        uploader.setBucketName(systemConfig.getQiNiuBucketName());
        return QiNiuUploadUtil.getUpToken(uploader);
    }

    /**
     * author: 赵杰
     * Business Description：通过key值获取系统配置
     *
     * @param key
     * @return
     */
    @Override
    public SystemConfigVo getSystemConfigByKey(String key) {
        return systemConfigMapper.getSystemConfigByKey(key);
    }
}
